package cn.edu.xmu.restfuldemo.model.VO;

import cn.edu.xmu.restfuldemo.model.BO.Goods;
import cn.edu.xmu.restfuldemo.model.PO.GoodsPo;
import cn.edu.xmu.restfuldemo.model.VoObject;
import lombok.*;

import java.time.LocalDateTime;

/**
 * @author RenJieZheng
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class GoodsVo implements VoObject {
    private Long id;
    private String name;
    private Long brandId;
    private Long freightId;
    private Long shopId;
    private String goodsSn;
    private String detail;
    private String imageUrl;
    private Byte disabled;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;

    public GoodsVo(GoodsPo goodsPo) {
        this.id = goodsPo.getId();
        this.name = goodsPo.getName();
        this.brandId = goodsPo.getBrandId();
        this.freightId = goodsPo.getFreightId();
        this.shopId = goodsPo.getShopId();
        this.goodsSn = goodsPo.getGoodsSn();
        this.detail = goodsPo.getDetail();
        this.imageUrl = goodsPo.getImageUrl();
        this.disabled = goodsPo.getDisabled();
        this.gmtCreate = goodsPo.getGmtCreate();
        this.gmtModified = goodsPo.getGmtModified();
    }

    /**
     * Goods->GoodsPo
     * @return
     */
    public Goods newGoods(){
        Goods goods = new Goods();
        goods.setId(this.id);
        goods.setName(this.name);
        goods.setBrandId(this.brandId);
        goods.setFreightId(this.freightId);
        goods.setShopId(this.shopId);
        goods.setGoodsSn(this.goodsSn);
        goods.setDetail(this.detail);
        goods.setImageUrl(this.imageUrl);
        goods.setDisabled(this.disabled);
        goods.setGmtCreate(this.gmtCreate);
        goods.setGmtModified(this.gmtModified);
        return goods;
    }

    @Override
    public Object createVo() {
        return this;
    }

    @Override
    public Object createSimpleVo() {
        return this;
    }
}